package com.sysmenu.dao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.orm.ibatis.SqlMapClientTemplate;

import com.pojo.SysmenuPojo;

public class SysmenuDaoImpl implements SysmenuDao {

	private SqlMapClientTemplate sqlMapClienet;

	public SqlMapClientTemplate getSqlMapClienet() {
		return sqlMapClienet;
	}

	public void setSqlMapClienet(SqlMapClientTemplate sqlMapClienet) {
		this.sqlMapClienet = sqlMapClienet;
	}

	public int addSysmenu(Map<String, Object> parameMap) {
		Object obj = sqlMapClienet.insert("addSysmenu", parameMap);
		if (obj == null) {
			return 0;
		}
		return (Integer) obj;
	}

	/**
	 * 菜单列表
	 * 
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public List<SysmenuPojo> searchMenuList(Map<String,Object> paraMap) {
		return sqlMapClienet.queryForList("searchSysmenu",paraMap);
	}
	public boolean deleteByIdString(String idString) {
		boolean isFlag = true;
		if (idString == null || "".equals(idString))
			return false;
		String ids = idString.substring(0,idString.length()-1);
		try {
			   Map<String,String> paraMap = new HashMap<String,String>();
			   paraMap.put("ids", ids);
				sqlMapClienet.delete("deleteSysmenuById",paraMap);
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		}
		return isFlag;
	}
	public int searchMenuCount() {
		Object obj = sqlMapClienet.queryForObject("searchSysmenucount");
		if (obj == null) {
			return 0;
		}
		return (Integer) obj;
	}
}
